		package com.zhihu_lvliangi_android.option.loading;

import android.R.integer;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
import android.text.format.Time;
import android.widget.Toast;

import com.android.file.cache.CacheUtil;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.zhihu_lvliangi_android.R;
import com.zhihu_lvliangi_android.option.HomePageActivity;
import com.zhihu_lvliangi_android.option.parent.ParentActivity;
import com.zhihu_lvliangi_android.service.DataFormat;
import com.zhihu_lvliangi_android.service.MobileApplication;
import com.zhihu_lvliangi_android.service.TaskID;
import com.zhihu_lvliangi_android.util.Constant;
import com.zhihu_lvliangi_android.util.RequestURL;

public class LoadingActivity extends ParentActivity  {
	

	@Override
	protected int getLayoutId() {
		return R.layout.loading;
	}

	@Override
	protected void setupViews() {
//		new Handler().postDelayed(new Runnable() {
//			 
//			@Override
//			public void run() {
//				startActivity(HomePageActivity.class);
//				finish();
//			}
//				
//		}, 1000);
		
		
		if (TextUtils.isEmpty(MobileApplication.cacheUtils.getAsString(Constant.CACHE_ZHENGWU_OBJ_1))) {
			MobileApplication.getInstance().clientTask.executeGet(TaskID.TASK_APP_ZHENGWU_COLUM_INIT_1
					, DataFormat.STRING, RequestURL.getGuideTypesForTheme(), this);
		}
		if (TextUtils.isEmpty(MobileApplication.cacheUtils.getAsString(Constant.CACHE_ZHENGWU_OBJ_2)) ) {
			MobileApplication.getInstance().clientTask.executeGet(TaskID.TASK_APP_ZHENGWU_COLUM_INIT_2
					, DataFormat.STRING, RequestURL.getGuideTypesForEnterprise(), this);
		}
		if (TextUtils.isEmpty(MobileApplication.cacheUtils.getAsString(Constant.CACHE_ZHENGWU_OBJ_DEPART)) ) {
			MobileApplication.getInstance().clientTask.executeGet(TaskID.TASK_APP_ZHENGWU_COLUM_INIT_3
					, DataFormat.STRING, RequestURL.getGuideTypesForDepartment(), this);
		}
		new Handler().postDelayed(new Runnable() {
			
			@Override
			public void run() {
				startActivity(HomePageActivity.class);
				finish();
			}
		}, 1000);
	
	}

	@Override
	protected void initialized() {
	}

	@Override
	protected void threadTask() {

	}
	
	@Override
	public void onResponse(Object response, Enum<?> reqId) {
		super.onResponse(response, reqId);
		switch ((TaskID)reqId) {
		case TASK_APP_ZHENGWU_COLUM_INIT_1:
			MobileApplication.cacheUtils.put(Constant.CACHE_ZHENGWU_OBJ_1, response.toString());
			break;
		case TASK_APP_ZHENGWU_COLUM_INIT_2:
			MobileApplication.cacheUtils.put(Constant.CACHE_ZHENGWU_OBJ_2, response.toString());
			break;
		case TASK_APP_ZHENGWU_COLUM_INIT_3:
			System.out.println("========="+response);
			MobileApplication.cacheUtils.put(Constant.CACHE_ZHENGWU_OBJ_DEPART, response.toString());
			break;

		default:
			break;
		}
	
	}
	
	@Override
	public void onErrorResponse(VolleyError error) {
		super.onErrorResponse(error);
		showShortToast("数据请求失败!");
		startActivity(HomePageActivity.class);
		finish();
	}
	


}
